/*
 * Jp_PlannifierIntervention.java
 *
 * Created on 20 avril 2008, 17:05
 */

package gui;

import IBO.IClientParticulier;
import IBO.IClientSociete;
import IBO.IIntervention;
import IBO.ITechnicien;
import IBO.IZoneGeographique;
import IUSECASE.IUC_Factory;
import boerrors.AdresseInexistantException;
import boerrors.ClientInexistantException;
import boerrors.CodePostalMinimumMultiplicityException;
import boerrors.ZoneMinimumMultiplicityException;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.painter.CompoundPainter;
import org.jdesktop.swingx.painter.GlossPainter;
import org.jdesktop.swingx.painter.MattePainter;
import org.jdesktop.swingx.painter.Painter;
import org.jdesktop.swingx.painter.PinstripePainter;

/**
 *
 * @author  olivierm
 */
public class Jp_PlannifierIntervention extends javax.swing.JPanel {
    
    private Frm_Application _parent = null;
    private IIntervention _intervention = null;
    
    private DefaultTableModel _modele = new DefaultTableModel();
    private String[] _cloName = {"Matricule", "Nom", "Prenom", "Telephone"};
    private DefaultComboBoxModel _zoneModel = new DefaultComboBoxModel();
    private Vector<IZoneGeographique> _zones = null;
    private Vector<ITechnicien> _techniciens = null;
    
    public void initComponents2(Frm_Application parent, IIntervention intervention) throws CodePostalMinimumMultiplicityException{
        try {
            this._parent = parent;
            this._intervention = intervention;
            this._modele.setColumnIdentifiers(this._cloName);
            this._zones = this._parent.getFactoryRmi().getGestionPlanning().listerZone();
            for (int i = 0; i < this._zones.size(); i++){
                this._zoneModel.addElement(this._zones.get(i).getLibelleZone());
            }
            fillFields();
            jXDatePicker.setDate(new java.util.Date());
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
    private void fillFields() throws CodePostalMinimumMultiplicityException{
        try {
            jtxt_Id.setText(String.valueOf(this._intervention.getIdIntervention()));
            jtxt_Priorite.setText(this._intervention.getPrioriteDemande());
            jcbb_Priorite.setSelectedItem(this._intervention.getPrioriteDemande());
            jcbb_Priorite.repaint();
            jtxt_Zone.setText(String.valueOf(this._intervention.getIAdresse().getICodePostal().getZone().getIdZone()) + " - " + this._intervention.getIAdresse().getICodePostal().getZone().getLibelleZone());
            jtxt_Rue.setText(this._intervention.getIAdresse().getRue());
            jtxt_Numero.setText(this._intervention.getIAdresse().getNumero());
            jtxt_Comune.setText(this._intervention.getIAdresse().getICodePostal().getVille());
            jtxt_Cp.setText(this._intervention.getIAdresse().getICodePostal().getCodePostal());
            jtxt_Commentaire.setText(this._intervention.getDescriptionDemande());
            DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
            Date dateDate = this._intervention.getDateDemande().getTime();
            String dateFormatee = dateFormat.format(dateDate); 
            jtxt_DateCreation.setText(dateFormatee);
        } catch (ZoneMinimumMultiplicityException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (AdresseInexistantException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
    /** Creates new form Jp_PlannifierIntervention */
    public Jp_PlannifierIntervention() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        jXPanel3 = new org.jdesktop.swingx.JXPanel();
        jXPanel4 = new org.jdesktop.swingx.JXPanel();
        jLabel11 = new javax.swing.JLabel();
        jcbb_Zone = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jXDatePicker = new org.jdesktop.swingx.JXDatePicker();
        jbtn_Rechercher = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jcbb_Priorite = new javax.swing.JComboBox();
        jXPanel5 = new org.jdesktop.swingx.JXPanel();
        jbtn_Assigner = new javax.swing.JButton();
        jbtn_Annuler = new javax.swing.JButton();
        jXPanel6 = new org.jdesktop.swingx.JXPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable_Techniciens = new javax.swing.JTable();
        jXPanel7 = new org.jdesktop.swingx.JXPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jbtn_Supprimer = new javax.swing.JButton();
        jXPanel2 = new org.jdesktop.swingx.JXPanel();
        jLabel2 = new javax.swing.JLabel();
        jtxt_Id = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtxt_DateCreation = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jbtn_ClientInfo = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxt_Commentaire = new javax.swing.JTextArea();
        jLabel7 = new javax.swing.JLabel();
        jtxt_Rue = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtxt_Numero = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jtxt_Cp = new javax.swing.JTextField();
        jtxt_Comune = new javax.swing.JTextField();
        jtxt_Zone = new javax.swing.JTextField();
        jtxt_Priorite = new javax.swing.JTextField();

        setLayout(new java.awt.BorderLayout());

        jPanel1.setBackground(new java.awt.Color(0, 102, 153));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Tahoma", 3, 14));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Plannification d'une intervention");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(554, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        add(jPanel1, java.awt.BorderLayout.NORTH);

        jXPanel1.setBackgroundPainter(getPainter());
        jXPanel1.setLayout(new java.awt.BorderLayout());

        jXPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Assignation"));
        jXPanel3.setLayout(new java.awt.BorderLayout());

        jLabel11.setText("Choisir la zone:");

        jcbb_Zone.setModel(_zoneModel);
        jcbb_Zone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbb_ZoneActionPerformed(evt);
            }
        });

        jLabel12.setText("Choisir la date:");

        jbtn_Rechercher.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/eye.png"))); // NOI18N
        jbtn_Rechercher.setText("Rechercher");
        jbtn_Rechercher.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RechercherActionPerformed(evt);
            }
        });

        jLabel13.setText("Choisir la priorité:");

        jcbb_Priorite.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Faible", "Moyen", "Urgent" }));

        javax.swing.GroupLayout jXPanel4Layout = new javax.swing.GroupLayout(jXPanel4);
        jXPanel4.setLayout(jXPanel4Layout);
        jXPanel4Layout.setHorizontalGroup(
            jXPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcbb_Zone, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jXDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jcbb_Priorite, 0, 129, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jbtn_Rechercher)
                .addContainerGap())
        );
        jXPanel4Layout.setVerticalGroup(
            jXPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jcbb_Zone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jXDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtn_Rechercher)
                    .addComponent(jLabel13)
                    .addComponent(jcbb_Priorite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jXPanel3.add(jXPanel4, java.awt.BorderLayout.NORTH);

        jbtn_Assigner.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/tick.png"))); // NOI18N
        jbtn_Assigner.setText("Assigner");
        jbtn_Assigner.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_AssignerActionPerformed(evt);
            }
        });

        jbtn_Annuler.setText("Annuler");
        jbtn_Annuler.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_AnnulerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel5Layout = new javax.swing.GroupLayout(jXPanel5);
        jXPanel5.setLayout(jXPanel5Layout);
        jXPanel5Layout.setHorizontalGroup(
            jXPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel5Layout.createSequentialGroup()
                .addContainerGap(596, Short.MAX_VALUE)
                .addComponent(jbtn_Assigner)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbtn_Annuler)
                .addContainerGap())
        );
        jXPanel5Layout.setVerticalGroup(
            jXPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtn_Annuler)
                    .addComponent(jbtn_Assigner))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jXPanel3.add(jXPanel5, java.awt.BorderLayout.SOUTH);

        jXPanel6.setLayout(new java.awt.BorderLayout());

        jTable_Techniciens.setModel(_modele);
        jScrollPane2.setViewportView(jTable_Techniciens);

        jXPanel6.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jXPanel3.add(jXPanel6, java.awt.BorderLayout.CENTER);

        jXPanel1.add(jXPanel3, java.awt.BorderLayout.CENTER);

        jXPanel7.setLayout(new java.awt.BorderLayout());

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        jbtn_Supprimer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/cancel.png"))); // NOI18N
        jbtn_Supprimer.setText("Supprimer intervention");
        jbtn_Supprimer.setFocusable(false);
        jbtn_Supprimer.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtn_Supprimer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtn_Supprimer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_SupprimerActionPerformed(evt);
            }
        });
        jToolBar1.add(jbtn_Supprimer);

        jXPanel7.add(jToolBar1, java.awt.BorderLayout.NORTH);

        jXPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Intervention details"));

        jLabel2.setText("Numéro d'intervention:");

        jtxt_Id.setEditable(false);

        jLabel3.setText("Date de création:");

        jtxt_DateCreation.setEditable(false);

        jLabel4.setText("Piorité:");

        jLabel5.setText("Zone:");

        jbtn_ClientInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/help.png"))); // NOI18N
        jbtn_ClientInfo.setText("Information du client");
        jbtn_ClientInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_ClientInfoActionPerformed(evt);
            }
        });

        jLabel6.setText("Commentaire:");

        jtxt_Commentaire.setColumns(20);
        jtxt_Commentaire.setEditable(false);
        jtxt_Commentaire.setRows(5);
        jScrollPane1.setViewportView(jtxt_Commentaire);

        jLabel7.setText("Rue:");

        jtxt_Rue.setEditable(false);

        jLabel8.setText("Numéro:");

        jtxt_Numero.setEditable(false);

        jLabel9.setText("Commune:");

        jLabel10.setText("Code postal:");

        jtxt_Cp.setEditable(false);

        jtxt_Comune.setEditable(false);

        jtxt_Zone.setEditable(false);

        jtxt_Priorite.setEditable(false);

        javax.swing.GroupLayout jXPanel2Layout = new javax.swing.GroupLayout(jXPanel2);
        jXPanel2.setLayout(jXPanel2Layout);
        jXPanel2Layout.setHorizontalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtn_ClientInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxt_Id, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE))
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxt_DateCreation, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE))
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtxt_Priorite, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                            .addComponent(jtxt_Zone, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel6)
                    .addComponent(jLabel9))
                .addGap(4, 4, 4)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jtxt_Rue)
                            .addComponent(jtxt_Comune, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jtxt_Numero, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                            .addComponent(jtxt_Cp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE))
                .addContainerGap())
        );
        jXPanel2Layout.setVerticalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7)
                    .addComponent(jtxt_Rue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxt_Numero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxt_Id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jXPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxt_DateCreation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jtxt_Priorite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jXPanel2Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jtxt_Comune, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtxt_Cp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jXPanel2Layout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5)
                                    .addComponent(jtxt_Zone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtn_ClientInfo))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())))
        );

        jXPanel7.add(jXPanel2, java.awt.BorderLayout.CENTER);

        jXPanel1.add(jXPanel7, java.awt.BorderLayout.NORTH);

        add(jXPanel1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_AnnulerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_AnnulerActionPerformed

        this.setVisible(false);

}//GEN-LAST:event_jbtn_AnnulerActionPerformed

    private void jbtn_ClientInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_ClientInfoActionPerformed
        try {

            Vector<IClientParticulier> listeCltP = this._parent.getFactoryRmi().getGestionClients().rechercherClientParticulier_NumClient(this._intervention.getIClient().getIdClient());
            System.out.println("DEBUG: Test si client P");
            if (listeCltP.size() > 0){
               System.out.println("DEBUG: Test client P OK");
               Jd_DetailsClientP jd_Tmp = new Jd_DetailsClientP(this._parent, true);
               jd_Tmp.initComponents2(this._parent, (IClientParticulier)listeCltP.get(0));
               jd_Tmp.setVisible(true);
            }else{
               System.out.println("DEBUG: Test si client S");
                Vector<IClientSociete> listeCltS = this._parent.getFactoryRmi().getGestionClients().rechercherClientSociete_NumClient(this._intervention.getIClient().getIdClient());
                Jd_DetailsClientS jd_Tmp = new Jd_DetailsClientS(this._parent, true);
               System.out.println("DEBUG: Test si client S");
               jd_Tmp.initComponents2(this._parent, (IClientSociete)listeCltS.get(0)); 
               jd_Tmp.setVisible(true);               
            }
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClientInexistantException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_jbtn_ClientInfoActionPerformed

    private void jbtn_RechercherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RechercherActionPerformed
        try {
            GregorianCalendar dateIntervention = new GregorianCalendar();
            dateIntervention.setTime(jXDatePicker.getDate());
            String[] objTmp = new String[4];
            this._modele.setRowCount(0);
            IUC_Factory factory = this._parent.getFactoryRmi();
            Vector<ITechnicien> lstTmp = factory.getGestionPlanning().listerTechniciens(jcbb_Zone.getSelectedItem().toString(), 
                                                                                        dateIntervention);
            this._techniciens = lstTmp;
            for (int i = 0; i < lstTmp.size(); i++) {
                objTmp[0] = String.valueOf(this._techniciens.get(i).getMatricule());
                objTmp[1] = this._techniciens.get(i).getNom();
                objTmp[2] = this._techniciens.get(i).getPrenom();
                objTmp[3] = this._techniciens.get(i).getTelephone();
                this._modele.addRow(objTmp);
            }
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        }
        
                                                                  
    }//GEN-LAST:event_jbtn_RechercherActionPerformed

    private void jcbb_ZoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbb_ZoneActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcbb_ZoneActionPerformed

    private void jbtn_AssignerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_AssignerActionPerformed
            GregorianCalendar dateIntervention = new GregorianCalendar();
            dateIntervention.setTime(jXDatePicker.getDate());
            ITechnicien tampon = this._techniciens.elementAt(jTable_Techniciens.getSelectedRow());
                try {
                    System.out.println("DEBUG Nom du technicien : " + tampon.getNom() + " " + tampon.getPrenom());
                    System.out.println("DEBUG ID intervention : " + _intervention.getIdIntervention());
                    System.out.println("DEBUG ID technicien : " + tampon.getMatricule());
                    System.out.println("DEBUG Description : " + _intervention.getDescriptionDemande());
                    IUC_Factory factory = this._parent.getRegistryFactory();
                    factory.getGestionPlanning().planifier(this._intervention, tampon, dateIntervention, jcbb_Priorite.getSelectedItem().toString());                                          
                    JOptionPane.showMessageDialog(this, "L'intervention est planifiée.","Opération de planification réussie", JOptionPane.INFORMATION_MESSAGE );
                    this.setVisible(false);
                    this._parent.rechargementListesIntervention();                
                } catch (RemoteException ex) {
                    JOptionPane.showMessageDialog(this, "Erreur de planification de l'intervention.","Opération de planification en échec", JOptionPane.ERROR_MESSAGE );
                    Logger.getLogger(Jd_CreerIntervention.class.getName()).log(Level.SEVERE, null, ex);
                }
}//GEN-LAST:event_jbtn_AssignerActionPerformed

    private void jbtn_SupprimerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_SupprimerActionPerformed

        try {                                            
            IUC_Factory factory = this._parent.getRegistryFactory();
            factory.getGestionPlanning().annuler(this._intervention.getIdIntervention());
            JOptionPane.showMessageDialog(this, "L'intervention est annulée.","Opération d'annulation réussie", JOptionPane.INFORMATION_MESSAGE );
            this.setVisible(false);
            this._parent.rechargementListesIntervention();
        } catch (RemoteException ex) {
            JOptionPane.showMessageDialog(this, "Erreur d'annulation de l'intervention.","Opération d'annulation en échec", JOptionPane.ERROR_MESSAGE );
            Logger.getLogger(Jd_CreerIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassCastException ex){
            JOptionPane.showMessageDialog(this, "Erreur d'annulation de l'intervention. ClassCastException Exception.","Opération d'annulation en échec", JOptionPane.ERROR_MESSAGE );
            Logger.getLogger(Jd_CreerIntervention.class.getName()).log(Level.SEVERE, null, ex);            
        }        
        
    }//GEN-LAST:event_jbtn_SupprimerActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable_Techniciens;
    private javax.swing.JToolBar jToolBar1;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXPanel jXPanel2;
    private org.jdesktop.swingx.JXPanel jXPanel3;
    private org.jdesktop.swingx.JXPanel jXPanel4;
    private org.jdesktop.swingx.JXPanel jXPanel5;
    private org.jdesktop.swingx.JXPanel jXPanel6;
    private org.jdesktop.swingx.JXPanel jXPanel7;
    private javax.swing.JButton jbtn_Annuler;
    private javax.swing.JButton jbtn_Assigner;
    private javax.swing.JButton jbtn_ClientInfo;
    private javax.swing.JButton jbtn_Rechercher;
    private javax.swing.JButton jbtn_Supprimer;
    private javax.swing.JComboBox jcbb_Priorite;
    private javax.swing.JComboBox jcbb_Zone;
    private javax.swing.JTextArea jtxt_Commentaire;
    private javax.swing.JTextField jtxt_Comune;
    private javax.swing.JTextField jtxt_Cp;
    private javax.swing.JTextField jtxt_DateCreation;
    private javax.swing.JTextField jtxt_Id;
    private javax.swing.JTextField jtxt_Numero;
    private javax.swing.JTextField jtxt_Priorite;
    private javax.swing.JTextField jtxt_Rue;
    private javax.swing.JTextField jtxt_Zone;
    // End of variables declaration//GEN-END:variables

    public Painter getPainter() {
        MattePainter mp = new MattePainter(Colors.LightBlue.alpha(0.5f));
        GlossPainter gp = new GlossPainter(Colors.White.alpha(0.3f),
                                GlossPainter.GlossPosition.TOP);
        PinstripePainter pp = new PinstripePainter(Colors.Gray.alpha(0.2f),
                                    45d);
        return (new CompoundPainter(mp, pp, gp));
    }    
    
}
